/**
* @Title: BookActionBySpring.java
* @Package com.ssh.web.action
* @Description: TODO(用一句话描述该文件做什么)
* @author antch,861710865@qq.com
* @date 2017年7月10日 下午1:30:23
* @version V1.0
*/

package com.ssh.web.action;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionSupport;
import com.ssh.domain.Book;
import com.ssh.service.BookService;

/**
 * @ClassName: BookActionBySpring
 * @Description: TODO(通过spring进行struts2的action管理)
 * @author antch,861710865@qq.com
 * @date 2017年7月10日 下午1:30:23
 *
 */
@Controller
@Scope(value = "prototype")
public class BookActionBySpring extends ActionSupport {

	/**
	 * @Fields serialVersionUID : TODO(用一句话描述这个变量表示什么)
	 */

	private static final long serialVersionUID = 1L;
	private String bookName;

	private Double bookPrice;

	public String getBookName() {
		return bookName;
	}

	public void setBookName(String bookName) {
		this.bookName = bookName;
	}

	public Double getBookPrice() {
		return bookPrice;
	}

	public void setBookPrice(Double bookPrice) {
		this.bookPrice = bookPrice;
	}

	@Autowired
	private BookService bookService;

	public void setBookService(BookService bookService) {
		this.bookService = bookService;
	}

	public String addBook() {
		System.out.println("****spring 管理action测试开始****");
		System.out.println("增加书籍");
		System.out.println("书籍名称：" + bookName + ",价格：" + bookPrice);
		if (null != bookService) {
			Book book = new Book();
			book.setBookName(bookName);
			book.setBookPrice(bookPrice);
			bookService.save(book);
		} else {
			System.out.println("注入失败，整合失败");
		}
		System.out.println("****spring 管理action测试结束****");

		return null;
	}
}
